package com.xhga.transaction.log;
import com.xhga.transaction.common.entity.TransactionLog;
import com.xhga.transaction.common.service.TransactionLogService;
import com.xhga.transaction.log.impl.TransactionLogServiceImpl;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.Date;


/**
 * 测试 dubbo 服务
 *
 * @author xhga
 * @since 2019-04-03
 */
@RestController
@RequestMapping("/log")
public class TestRpcServerController {
    @Autowired
    private TransactionLogService transactionLogService;
    @RequestMapping("/testApi")
    @ResponseBody
    public String testApi(){
        return"a";
    }


    /*-----------------------------别看了,有鬼----------------------------*/
    /**
     * 测试rpc服务
     * @return
     */
    @RequestMapping("/add")
    @ResponseBody
    public String testLog(){
        TransactionLog transactionLog = new TransactionLog();
        transactionLog.setCentreNo("test");
        transactionLog.setPrepareCount(2);
        transactionLog.setCount(2);
        transactionLog.setFailedCount(1);
        int i = transactionLogService.addTransactionLog(transactionLog);
        return "操作:" + i;
    }
    /**
     * updateLog
     * @return
     */
    @RequestMapping("/updateLog")
    @ResponseBody
    public String updateLog(@Param("centreNo") String centreNo) throws Exception {
        transactionLogService.updateFailedCount(centreNo,"");
        return "操作:";
    }


}
